package org.mikeliu.exp2.homework4;

import java.util.Scanner;

class Circle {
	private int radius;

	public Circle() {
		this.radius = 2;
		System.out.println("This is a constructor with no para.");
	}

	public Circle(int radius) {
		setRadius(radius);
		System.out.println("This is a constructor with para.");
	}

	public int getRadius() {
		return radius;
	}

	public void setRadius(int radius) {
		if (radius <= 0)
			this.radius = 2;
		else
			this.radius = radius;
	}

	public double getArea() {
		return Math.PI * this.radius * this.radius;
	}

	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}

}

public class Homework4 {
	public static void main(String[] args) {
		Circle c1 = new Circle();
		System.out.println(c1);
		System.out.printf("%.2f\n", c1.getArea());
		Circle c2 = new Circle();
		System.out.println(c2);
		System.out.printf("%.2f\n", c2.getArea());
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		c2.setRadius(r);
		System.out.println(c2);
		System.out.printf("%.2f\n", c2.getArea());
		r = scanner.nextInt();
		Circle c3 = new Circle(r);
		System.out.println(c3);
		System.out.printf("%.2f\n", c3.getArea());
	}
}
